﻿(function () {

    // Defining variables that need to be available to some functions
    var map, infoWindow;

    window.onload = function () {

        // Creating a map
        var options = {
            zoom: 10,
            center: new google.maps.LatLng(31.416944, 121.490936),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };

        map = new google.maps.Map(document.getElementById('map'), options);

        // Adding a marker
        var marker = new google.maps.Marker({
            position: new google.maps.LatLng(31.416944, 121.490936),
            map: map,
            title: 'Master HaKu',
            icon: '/Images/icon/wow.png'
        });

        google.maps.event.addListener(marker, 'click', function () {

            // Check to see if an InfoWindow already exists
            if (!infoWindow) {
                infoWindow = new google.maps.InfoWindow();
            }

            // Creating the content  
            var content = '<div class="info">' +
                '<img src="/Images/cat.jpg" alt="" />' +
                '<h2>Master HaKu</h2>' +
                '<p>technical expert <br /> with vision & creation</p>' +
                '<p><a href="http://www.cnblogs.com/davidgu" target="_blank">blog</a></p>' +
                '</div>';
            
            // Setting the content of the InfoWindow
            infoWindow.setContent(content);

            // Opening the InfoWindow
            infoWindow.open(map, marker);

        });

        // Triggering the click event
        google.maps.event.trigger(marker, 'click');

    };

})();


